package controller

import (
	"gitee.com/csingo/cResponse"
	"github.com/gin-gonic/gin"
	"satis-go/app/collector/service"
	"satis-go/base/collector"
)

type IncludesController struct{}

func (i *IncludesController) ControllerName() (app, name string) {
	return "collector", "IncludesController"
}

func (i *IncludesController) Add(ctx *gin.Context) (int, interface{}) {
	req := &collector.IncludesServiceAddReq{}
	err := ctx.BindJSON(req)
	if err != nil {
		return cResponse.Api(ctx, nil, err)
	}
	rsp, err := (&service.IncludesService{}).Add(ctx, req)

	return cResponse.Api(ctx, rsp, err)
}

func (i *IncludesController) Del(ctx *gin.Context) (int, interface{}) {
	req := &collector.IncludesServiceDelReq{}
	err := ctx.BindJSON(req)
	if err != nil {
		return cResponse.Api(ctx, nil, err)
	}
	rsp, err := (&service.IncludesService{}).Del(ctx, req)

	return cResponse.Api(ctx, rsp, err)
}

func (i *IncludesController) All(ctx *gin.Context) (int, interface{}) {
	rsp, err := (&service.IncludesService{}).All(ctx, nil)

	return cResponse.Api(ctx, rsp, err)
}
